<?php
class Quiz{
	public $db;
	public function __construct()
	{
		$this->db = new Mysql();		
	}
	
	public function getAllCate()
	{
		$sql = "SELECT * FROM q_quiz_cate ";
		return $this->db->selectAllCache($sql);
		
	}
    public function getCateByUserAndName($uid,$name){
		$sql = "SELECT * FROM q_quiz_cate WHERE uid = '$uid' AND name='$name' ";
		return $this->db->selectRow($sql);
		
	}
	public function getCateByUser($uid){
		$sql = "SELECT * FROM q_quiz_cate WHERE uid = '$uid' ORDER BY islast DESC,id DESC";
		return $this->db->selectAll($sql);
		
	}
	public function getQuizByTitle($title,$uid){
		$sql = "SELECT 1 FROM q_quiz WHERE `title` = '$title' AND uid = $uid";
		if ($this->db->getRow($sql)){
			return true;
		}else {
			return  false;
		}
	}
}